package ink.yql.util;

import ink.yql.model.AddressBook;
import yql.myutil.MyStringUtil;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 * @author YQL
 * 校验方法
 */
public class Check implements Serializable {
    public static boolean addressBook(AddressBook addressBook){
        Field[] fields = MyStringUtil.getObjectAllFields(addressBook);
        for (Field field : fields) {
            field.setAccessible(true);
            if (field.getName().endsWith("id")){
                continue;
            }
            try {
                if (field.get(addressBook) ==null){
                    return false;
                }
            } catch (IllegalAccessException e) {
                System.out.println(e);
                return false;
            }
        }
        return true;
    }
}
